/*===================================================================
* x Labor Graphics Engine
* This library is a professional game engine

* author : Rock Mao
* created : 9-5-2005
* filename: LaborCylinder.h

* purpose : 
=======================================================================*/

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Include Guard
#ifndef __LABORCYLINDER_H__
#define __LABORCYLINDER_H__

//#include "LaborPoint.h"
#include "LaborMathDecl.h"
#include "LaborBoundingSphere.h"
#include "../LaborCoreDef.h"
NAMESPACE_LABOR3D_BEGIN
class  LABORCORE_API CLCylinder
{
public:
	CLCylinder( const CLPoint3 &p, const CLPoint3 &d, float r );
	CLCylinder( const CLCylinder &c );
	CLCylinder();
	~CLCylinder();

	void  getAxis( CLPoint3 &aPos,  CLPoint3 &aDir ) const;
	float getRadius(void) const;

	virtual void	getCenter( CLPoint3 &center ) const;
	virtual float	getScalarVolume(void) const;
	virtual void	getBounds( CLPoint3 &min, CLPoint3 &max ) const;

	void setValue( const CLPoint3 &p, const CLPoint3 &d, float r );
	void setAxis( const CLPoint3 &p, const CLPoint3 &d );
	void setRadius( float r );

	bool intersect(const CLCylinder &cylinder) const;
	bool intersect( const CLSphere &sphere ) const;
	bool intersect( const CLAABB &box ) const;

private:
	CLPoint3  m_axisPos;
	CLPoint3	m_axisDir;
	float	m_radius;

};

inline
void CLCylinder::setValue( const CLPoint3 &p, const CLPoint3 &d, float r )
{
	m_axisPos = p;
	m_axisDir = d;
	m_radius = r;
}


inline
void CLCylinder::setAxis( const CLPoint3 &p, const CLPoint3 &d )
{
	m_axisPos = p;
	m_axisDir = d;
}


inline
void CLCylinder::setRadius( float r )
{
	m_radius = r;
}


inline
void CLCylinder::getAxis( CLPoint3 &apos,  CLPoint3 &adir ) const
{
	adir = m_axisDir;
	apos = m_axisPos;
}


inline
float CLCylinder::getRadius(void) const
{
	return m_radius;
}

NAMESPACE_LABOR3D_END
#endif